﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.ComponentModel;
using System.Web.UI.Design.WebControls;
using System.Web.UI.Design;
using System.Web.UI.WebControls;

namespace InvoiceChecking.Web.UI
{
    /// <summary>
    /// A designer class for a strongly typed repeater <c>SunAccountCodeRepeater</c>
    /// </summary>
	public class SunAccountCodeRepeaterDesigner : System.Web.UI.Design.ControlDesigner
	{
	    /// <summary>
        /// Initializes a new instance of the <see cref="T:SunAccountCodeRepeaterDesigner"/> class.
        /// </summary>
		public SunAccountCodeRepeaterDesigner()
		{
		}

        /// <summary>
        /// Initializes the control designer and loads the specified component.
        /// </summary>
        /// <param name="component">The control being designed.</param>
		public override void Initialize(IComponent component)
		{
			if (!(component is SunAccountCodeRepeater))
			{ 
				throw new ArgumentException("Component is not a SunAccountCodeRepeater."); 
			} 
			base.Initialize(component); 
			base.SetViewFlags(ViewFlags.TemplateEditing, true); 
		}


		/// <summary>
		/// Generate HTML for the designer
		/// </summary>
		/// <returns>a string of design time HTML</returns>
		public override string GetDesignTimeHtml()
		{

			// Get the instance this designer applies to
			//
			SunAccountCodeRepeater z = (SunAccountCodeRepeater)Component;
			z.DataBind();

			return base.GetDesignTimeHtml();
		}
	}

    /// <summary>
    /// A strongly typed repeater control for the <see cref="SunAccountCodeRepeater"/> Type.
    /// </summary>
	[Designer(typeof(SunAccountCodeRepeaterDesigner))]
	[ParseChildren(true)]
	[ToolboxData("<{0}:SunAccountCodeRepeater runat=\"server\"></{0}:SunAccountCodeRepeater>")]
	public class SunAccountCodeRepeater : CompositeDataBoundControl, System.Web.UI.INamingContainer
	{
	    /// <summary>
        /// Initializes a new instance of the <see cref="T:SunAccountCodeRepeater"/> class.
        /// </summary>
		public SunAccountCodeRepeater()
		{
		}

		/// <summary>
        /// Gets a <see cref="T:System.Web.UI.ControlCollection"></see> object that represents the child controls for a specified server control in the UI hierarchy.
        /// </summary>
        /// <value></value>
        /// <returns>The collection of child controls for the specified server control.</returns>
		public override ControlCollection Controls
		{
			get
			{
				this.EnsureChildControls();
				return base.Controls;
			}
		}

		private ITemplate m_headerTemplate;
		/// <summary>
        /// Gets or sets the header template.
        /// </summary>
        /// <value>The header template.</value>
		[Browsable(false)]
		[TemplateContainer(typeof(SunAccountCodeItem))]
		[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
		public ITemplate HeaderTemplate
		{
			get { return m_headerTemplate; }
			set { m_headerTemplate = value; }
		}

		private ITemplate m_itemTemplate;
		/// <summary>
        /// Gets or sets the item template.
        /// </summary>
        /// <value>The item template.</value>
		[Browsable(false)]
		[TemplateContainer(typeof(SunAccountCodeItem))]
		[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
		public ITemplate ItemTemplate
		{
			get { return m_itemTemplate; }
			set { m_itemTemplate = value; }
		}

		private ITemplate m_seperatorTemplate;
		/// <summary>
        /// Gets or sets the Seperator Template
        /// </summary>
        [Browsable(false)]
        [TemplateContainer(typeof(SunAccountCodeItem))]
        [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
        public ITemplate SeperatorTemplate
        {
            get { return m_seperatorTemplate; }
            set { m_seperatorTemplate = value; }
        }

		private ITemplate m_altenateItemTemplate;
        /// <summary>
        /// Gets or sets the alternating item template.
        /// </summary>
        /// <value>The alternating item template.</value>
		[Browsable(false)]
		[TemplateContainer(typeof(SunAccountCodeItem))]
		[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
		public ITemplate AlternatingItemTemplate
		{
			get { return m_altenateItemTemplate; }
			set { m_altenateItemTemplate = value; }
		}

		private ITemplate m_footerTemplate;
        /// <summary>
        /// Gets or sets the footer template.
        /// </summary>
        /// <value>The footer template.</value>
		[Browsable(false)]
		[TemplateContainer(typeof(SunAccountCodeItem))]
		[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
		public ITemplate FooterTemplate
		{
			get { return m_footerTemplate; }
			set { m_footerTemplate = value; }
		}
		
		
		/// <summary>
        /// Overridden and Empty so that span tags are not written
        /// </summary>
        /// <param name="writer"></param>
        public override void RenderBeginTag(HtmlTextWriter writer)
        {
            
        }

        /// <summary>
        /// Overridden and Empty so that span tags are not written
        /// </summary>
        /// <param name="writer"></param>
        public override void RenderEndTag(HtmlTextWriter writer)
        {
                
        }		

//      /// <summary>
//      /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
//      /// </summary>
//		protected override void CreateChildControls()
//		{
//			if (ChildControlsCreated)
//			{
//				return;
//			}
//			Controls.Clear();
//
//			if (m_headerTemplate != null)
//			{
//				Control headerItem = new Control();
//				m_headerTemplate.InstantiateIn(headerItem);
//				Controls.Add(headerItem);
//			}
//
//			
//			if (m_footerTemplate != null)
//			{
//				Control footerItem = new Control();
//				m_footerTemplate.InstantiateIn(footerItem);
//				Controls.Add(footerItem);
//			}
//			ChildControlsCreated = true;
//		}
		
		/// <summary>
      /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
      /// </summary>
		protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding)
      {
         int pos = 0;

         if (dataBinding)
         {
            //Instantiate the Header template (if exists)
            if (m_headerTemplate != null)
            {
                Control headerItem = new Control();
                m_headerTemplate.InstantiateIn(headerItem);
                Controls.Add(headerItem);
            }
			if (dataSource != null)
			{
				foreach (object o in dataSource)
				{
						InvoiceChecking.Entities.SunAccountCode entity = o as InvoiceChecking.Entities.SunAccountCode;
						SunAccountCodeItem container = new SunAccountCodeItem(entity);
	
						if (m_itemTemplate != null && (pos % 2) == 0)
						{
							m_itemTemplate.InstantiateIn(container);
							
							if (m_seperatorTemplate != null)
							{
								m_seperatorTemplate.InstantiateIn(container);
							}
						}
						else
						{
							if (m_altenateItemTemplate != null)
							{
								m_altenateItemTemplate.InstantiateIn(container);
								if (m_seperatorTemplate != null)
								{
									m_seperatorTemplate.InstantiateIn(container);
								}

							}
							else if (m_itemTemplate != null)
							{
								m_itemTemplate.InstantiateIn(container);
								if (m_seperatorTemplate != null)
								{
									m_seperatorTemplate.InstantiateIn(container);
								}

							}
							else
							{
								// no template !!!
							}
						}
						Controls.Add(container);
						
						container.DataBind();
						
						pos++;
				}
			}            
			//Instantiate the Footer template (if exists)
            if (m_footerTemplate != null)
            {
                Control footerItem = new Control();
                m_footerTemplate.InstantiateIn(footerItem);
                Controls.Add(footerItem);
            }				
		 }
			
			return pos;
		}
		
      /// <summary>
      /// Raises the <see cref="E:System.Web.UI.Control.PreRender"></see> event.
      /// </summary>
      /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
		protected override void OnPreRender(EventArgs e)
		{
			base.DataBind();
		}

		#region Design time
        /// <summary>
        /// Renders at design time.
        /// </summary>
        /// <returns>a  string of the Designed HTML</returns>
		internal string RenderAtDesignTime()
		{			
			return "Designer currently not implemented"; 
		}

		#endregion
	}

    /// <summary>
    /// A wrapper type for the entity
    /// </summary>
	[System.ComponentModel.ToolboxItem(false)]
	public class SunAccountCodeItem : System.Web.UI.Control, System.Web.UI.INamingContainer
	{
		private InvoiceChecking.Entities.SunAccountCode _entity;

        /// <summary>
        /// Initializes a new instance of the <see cref="T:SunAccountCodeItem"/> class.
        /// </summary>
		public SunAccountCodeItem()
			: base()
		{ }

        /// <summary>
        /// Initializes a new instance of the <see cref="T:SunAccountCodeItem"/> class.
        /// </summary>
		public SunAccountCodeItem(InvoiceChecking.Entities.SunAccountCode entity)
			: base()
		{
			_entity = entity;
		}
		
        /// <summary>
        /// Gets the SunDb
        /// </summary>
        /// <value>The SunDb.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String SunDb
		{
			get { return _entity.SunDb; }
		}
        /// <summary>
        /// Gets the AccntCode
        /// </summary>
        /// <value>The AccntCode.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AccntCode
		{
			get { return _entity.AccntCode; }
		}
        /// <summary>
        /// Gets the Lookup
        /// </summary>
        /// <value>The Lookup.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String Lookup
		{
			get { return _entity.Lookup; }
		}
        /// <summary>
        /// Gets the Updated
        /// </summary>
        /// <value>The Updated.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String Updated
		{
			get { return _entity.Updated; }
		}
        /// <summary>
        /// Gets the AccntName
        /// </summary>
        /// <value>The AccntName.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AccntName
		{
			get { return _entity.AccntName; }
		}
        /// <summary>
        /// Gets the AccntType
        /// </summary>
        /// <value>The AccntType.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AccntType
		{
			get { return _entity.AccntType; }
		}
        /// <summary>
        /// Gets the BalnceOpn
        /// </summary>
        /// <value>The BalnceOpn.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String BalnceOpn
		{
			get { return _entity.BalnceOpn; }
		}
        /// <summary>
        /// Gets the Suspend
        /// </summary>
        /// <value>The Suspend.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String Suspend
		{
			get { return _entity.Suspend; }
		}
        /// <summary>
        /// Gets the ConvCntrl
        /// </summary>
        /// <value>The ConvCntrl.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String ConvCntrl
		{
			get { return _entity.ConvCntrl; }
		}
        /// <summary>
        /// Gets the ConvCode
        /// </summary>
        /// <value>The ConvCode.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String ConvCode
		{
			get { return _entity.ConvCode; }
		}
        /// <summary>
        /// Gets the SuppReval
        /// </summary>
        /// <value>The SuppReval.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String SuppReval
		{
			get { return _entity.SuppReval; }
		}
        /// <summary>
        /// Gets the CommitAcc
        /// </summary>
        /// <value>The CommitAcc.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String CommitAcc
		{
			get { return _entity.CommitAcc; }
		}
        /// <summary>
        /// Gets the Comments
        /// </summary>
        /// <value>The Comments.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String Comments
		{
			get { return _entity.Comments; }
		}
        /// <summary>
        /// Gets the EnterAnal
        /// </summary>
        /// <value>The EnterAnal.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String EnterAnal
		{
			get { return _entity.EnterAnal; }
		}
        /// <summary>
        /// Gets the AddCode
        /// </summary>
        /// <value>The AddCode.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AddCode
		{
			get { return _entity.AddCode; }
		}
        /// <summary>
        /// Gets the DirectDb
        /// </summary>
        /// <value>The DirectDb.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String DirectDb
		{
			get { return _entity.DirectDb; }
		}
        /// <summary>
        /// Gets the Priority
        /// </summary>
        /// <value>The Priority.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String Priority
		{
			get { return _entity.Priority; }
		}
        /// <summary>
        /// Gets the PayMethod
        /// </summary>
        /// <value>The PayMethod.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String PayMethod
		{
			get { return _entity.PayMethod; }
		}
        /// <summary>
        /// Gets the CreditLim
        /// </summary>
        /// <value>The CreditLim.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Decimal CreditLim
		{
			get { return _entity.CreditLim; }
		}
        /// <summary>
        /// Gets the PaymntDay
        /// </summary>
        /// <value>The PaymntDay.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Int16 PaymntDay
		{
			get { return _entity.PaymntDay; }
		}
        /// <summary>
        /// Gets the PaymntTrm
        /// </summary>
        /// <value>The PaymntTrm.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String PaymntTrm
		{
			get { return _entity.PaymntTrm; }
		}
        /// <summary>
        /// Gets the DiscDays
        /// </summary>
        /// <value>The DiscDays.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Int16 DiscDays
		{
			get { return _entity.DiscDays; }
		}
        /// <summary>
        /// Gets the Discount
        /// </summary>
        /// <value>The Discount.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Decimal Discount
		{
			get { return _entity.Discount; }
		}
        /// <summary>
        /// Gets the DiscDays2
        /// </summary>
        /// <value>The DiscDays2.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Int16 DiscDays2
		{
			get { return _entity.DiscDays2; }
		}
        /// <summary>
        /// Gets the Discount2
        /// </summary>
        /// <value>The Discount2.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Decimal Discount2
		{
			get { return _entity.Discount2; }
		}
        /// <summary>
        /// Gets the LastTrans
        /// </summary>
        /// <value>The LastTrans.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String LastTrans
		{
			get { return _entity.LastTrans; }
		}
        /// <summary>
        /// Gets the TransPres
        /// </summary>
        /// <value>The TransPres.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String TransPres
		{
			get { return _entity.TransPres; }
		}
        /// <summary>
        /// Gets the AccBalnce
        /// </summary>
        /// <value>The AccBalnce.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Decimal AccBalnce
		{
			get { return _entity.AccBalnce; }
		}
        /// <summary>
        /// Gets the OrdBalnce
        /// </summary>
        /// <value>The OrdBalnce.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Decimal OrdBalnce
		{
			get { return _entity.OrdBalnce; }
		}
        /// <summary>
        /// Gets the AllocProg
        /// </summary>
        /// <value>The AllocProg.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AllocProg
		{
			get { return _entity.AllocProg; }
		}
        /// <summary>
        /// Gets the UserArea
        /// </summary>
        /// <value>The UserArea.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String UserArea
		{
			get { return _entity.UserArea; }
		}
        /// <summary>
        /// Gets the AnalA0
        /// </summary>
        /// <value>The AnalA0.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA0
		{
			get { return _entity.AnalA0; }
		}
        /// <summary>
        /// Gets the AnalA1
        /// </summary>
        /// <value>The AnalA1.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA1
		{
			get { return _entity.AnalA1; }
		}
        /// <summary>
        /// Gets the AnalA2
        /// </summary>
        /// <value>The AnalA2.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA2
		{
			get { return _entity.AnalA2; }
		}
        /// <summary>
        /// Gets the AnalA3
        /// </summary>
        /// <value>The AnalA3.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA3
		{
			get { return _entity.AnalA3; }
		}
        /// <summary>
        /// Gets the AnalA4
        /// </summary>
        /// <value>The AnalA4.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA4
		{
			get { return _entity.AnalA4; }
		}
        /// <summary>
        /// Gets the AnalA5
        /// </summary>
        /// <value>The AnalA5.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA5
		{
			get { return _entity.AnalA5; }
		}
        /// <summary>
        /// Gets the AnalA6
        /// </summary>
        /// <value>The AnalA6.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA6
		{
			get { return _entity.AnalA6; }
		}
        /// <summary>
        /// Gets the AnalA7
        /// </summary>
        /// <value>The AnalA7.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA7
		{
			get { return _entity.AnalA7; }
		}
        /// <summary>
        /// Gets the AnalA8
        /// </summary>
        /// <value>The AnalA8.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA8
		{
			get { return _entity.AnalA8; }
		}
        /// <summary>
        /// Gets the AnalA9
        /// </summary>
        /// <value>The AnalA9.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String AnalA9
		{
			get { return _entity.AnalA9; }
		}
        /// <summary>
        /// Gets the TaxCode
        /// </summary>
        /// <value>The TaxCode.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String TaxCode
		{
			get { return _entity.TaxCode; }
		}
        /// <summary>
        /// Gets the Data1
        /// </summary>
        /// <value>The Data1.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String Data1
		{
			get { return _entity.Data1; }
		}
        /// <summary>
        /// Gets the Settlement
        /// </summary>
        /// <value>The Settlement.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String Settlement
		{
			get { return _entity.Settlement; }
		}
        /// <summary>
        /// Gets the LinkAcc
        /// </summary>
        /// <value>The LinkAcc.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String LinkAcc
		{
			get { return _entity.LinkAcc; }
		}
        /// <summary>
        /// Gets the DefBankCode
        /// </summary>
        /// <value>The DefBankCode.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String DefBankCode
		{
			get { return _entity.DefBankCode; }
		}
        /// <summary>
        /// Gets the OverTolInd
        /// </summary>
        /// <value>The OverTolInd.</value>
		[System.ComponentModel.Bindable(true)]
		public System.String OverTolInd
		{
			get { return _entity.OverTolInd; }
		}
        /// <summary>
        /// Gets the TolDays
        /// </summary>
        /// <value>The TolDays.</value>
		[System.ComponentModel.Bindable(true)]
		public System.Int16 TolDays
		{
			get { return _entity.TolDays; }
		}

	}
}
